<template id="tmp-item-edit">
    <el-dialog
        v-if="item"
        :title="item.name"
        :show-close="false"
        :close-on-click-modal="false"
        :visible.sync="visible"
        width="50%">

        <div class="item">
            <el-row :gutter="20">
                <el-col :span="4"><div style="text-align: end">

                        <img :src="item.iconPath" style="height: 50px; width: 50px" alt="">
                    </div>
                </el-col>
                <el-col :span="16">

                    <el-tabs>
                        <el-tab-pane label="基础" >
                            <el-form ref="form" label-width="80px" size="mini">
                                <el-form-item label="名称">
                                    <el-input v-model="item.name"></el-input>
                                </el-form-item>

                                <el-form-item label="品质">
                                    <el-select v-model="item.Quality" placeholder="请选择">
                                        <el-option label="灰色粗糙" :value="0"></el-option>
                                        <el-option label="白色普通" :value="1"></el-option>
                                        <el-option label="绿色精良" :value="2"></el-option>
                                        <el-option label="蓝色优秀" :value="3"></el-option>
                                        <el-option label="紫色" :value="4"></el-option>
                                        <el-option label="橙装" :value="5"></el-option>
                                        <el-option label="金色" :value="6"></el-option>
                                    </el-select>
                                </el-form-item>

                                <el-form-item label="绑定">
                                    <el-select v-model="item.bonding" placeholder="请选择">
                                        <el-option label="不绑定" :value="0"></el-option>
                                        <el-option label="拾取绑定" :value="1"></el-option>
                                        <el-option label="装备绑定" :value="2"></el-option>
                                        <el-option label="使用绑定" :value="3"></el-option>
                                        <el-option label="任务物品" :value="4"></el-option>
                                        <el-option label="任务物品" :value="5"></el-option>
                                    </el-select>
                                </el-form-item>

                                <el-form-item label="类型">
                                    <component-item-class-select v-model="item.classes"></component-item-class-select>
                                </el-form-item>

                                <el-form-item label="位置">
                                    <el-select v-model="item.InventoryType" placeholder="请选择">
                                        <el-option label="不可装备" :value="0"></el-option>
                                        <el-option label="头" :value="1"></el-option>
                                        <el-option label="脖子" :value="2"></el-option>
                                        <el-option label="肩膀" :value="3"></el-option>
                                        <el-option label="身体" :value="4"></el-option>
                                        <el-option label="胸部" :value="5"></el-option>
                                        <el-option label="腰" :value="6"></el-option>
                                        <el-option label="腿" :value="7"></el-option>
                                        <el-option label="脚" :value="8"></el-option>
                                        <el-option label="手腕" :value="9"></el-option>
                                        <el-option label="手" :value="10"></el-option>
                                        <el-option label="手指" :value="11"></el-option>
                                        <el-option label="饰品" :value="12"></el-option>
                                        <el-option label="武器" :value="13"></el-option>
                                        <el-option label="盾" :value="14"></el-option>
                                        <el-option label="不等" :value="15"></el-option>
                                        <el-option label="披风" :value="16"></el-option>
                                        <el-option label="双手武器" :value="17"></el-option>
                                        <el-option label="背包" :value="18"></el-option>
                                        <el-option label="粗呢大衣" :value="19"></el-option>
                                        <el-option label="长袍" :value="20"></el-option>
                                        <el-option label="主手武器" :value="21"></el-option>
                                        <el-option label="副手手武器" :value="22"></el-option>
                                        <el-option label="HOLDABL" :value="23"></el-option>
                                        <el-option label="弹药" :value="24"></el-option>
                                        <el-option label="投掷" :value="25"></el-option>
                                        <el-option label="远程" :value="26"></el-option>
                                        <el-option label="箭袋" :value="27"></el-option>
                                        <el-option label="圣物" :value="28"></el-option>
                                    </el-select>
                                </el-form-item>

                                <el-form-item label="物品等级">
                                    <el-input type="number" size="mini" min="0" max="200" v-model="item.ItemLevel"></el-input>
                                </el-form-item>
                                <el-form-item label="需求等级">
                                    <el-input type="number" size="mini" min="0" max="200" v-model="item.RequiredLevel"></el-input>
                                </el-form-item>

                                <el-form-item label="购买价格">
                                    <el-input type="number" size="mini" min="0" max="999999999" v-model="item.BuyPrice"></el-input>
                                </el-form-item>
                                <el-form-item label="出售价格">
                                    <el-input type="number" size="mini" min="0" max="999999999" v-model="item.SellPrice"></el-input>
                                </el-form-item>
                                <el-form-item label="堆叠数量">
                                    <el-input
                                        size="mini"
                                        placeholder="请输入内容"
                                        type="number"
                                        v-model="item.stackable">
                                    </el-input>
                                </el-form-item>

                                <el-form-item label="食物类型">
                                    <el-select v-model="item.FoodType" placeholder="请选择">
                                        <el-option label="非食物" :value="0"></el-option>
                                        <el-option label="肉" :value="1"></el-option>
                                        <el-option label="鱼" :value="2"></el-option>
                                        <el-option label="奶酪" :value="3"></el-option>
                                        <el-option label="面包" :value="4"></el-option>
                                        <el-option label="蘑菇" :value="5"></el-option>
                                        <el-option label="水果" :value="6"></el-option>
                                        <el-option label="生肉" :value="7"></el-option>
                                        <el-option label="生鱼" :value="8"></el-option>
                                    </el-select>
                                </el-form-item>

                                <el-form-item label="持续时间">

                                    <el-input placeholder="请输入内容" v-model="item.duration" class="input-with-select">
                                        <el-select v-model="item.flagsCustom" slot="append" placeholder="请选择">
                                            <el-option label="游戏时间（秒）" :value="0"></el-option>
                                            <el-option label="真实时间（秒）" :value="1"></el-option>
                                        </el-select>

                                    </el-input>
                                </el-form-item>

                                <el-form-item label="描述">
                                    <el-input type="textarea" v-model="item.description"></el-input>
                                </el-form-item>


                            </el-form>
                        </el-tab-pane>
                        <el-tab-pane label="武器/护甲" >
                            <el-form ref="form" label-width="80px" size="mini">
                                <el-form-item label="耐久">
                                    <el-input type="number" size="mini" min="0" max="99999" v-model="item.MaxDurability"></el-input>
                                </el-form-item>

                                <el-form-item label="速度">
                                    <el-input type="number" size="mini" min="0" max="99999" v-model="item.delay"></el-input>
                                </el-form-item>
                                <el-form-item label="护甲">
                                    <el-input type="number" size="mini" min="0" max="99999" v-model="item.armor"></el-input>
                                </el-form-item>
                                <el-form-item label="格挡">
                                    <el-input type="number" size="mini" min="0" max="99999" v-model="item.block"></el-input>
                                </el-form-item>

                                <el-tabs value="first" type="border-card">
                                    <el-tab-pane label="伤害1" name="first">
                                        <el-form-item label="伤害类型">
                                            <el-select v-model="item.dmg_type1" placeholder="请选择">
                                                <el-option label="普通" :value="0"></el-option>
                                                <el-option label="神圣" :value="1"></el-option>
                                                <el-option label="火焰" :value="2"></el-option>
                                                <el-option label="自然" :value="3"></el-option>
                                                <el-option label="冰霜" :value="4"></el-option>
                                                <el-option label="暗影" :value="5"></el-option>
                                                <el-option label="奥术" :value="6"></el-option>
                                            </el-select>
                                        </el-form-item>
                                        <el-form-item label="最小伤害">
                                            <el-input type="number" size="mini" min="0" max="99999" v-model="item.dmg_min1"></el-input>
                                        </el-form-item>
                                        <el-form-item label="最大伤害">
                                            <el-input type="number" size="mini" min="0" max="99999" v-model="item.dmg_max1"></el-input>
                                        </el-form-item>
                                    </el-tab-pane>
                                    <el-tab-pane label="伤害2" name="second"><el-form-item label="伤害类型">
                                            <el-select v-model="item.dmg_type2" placeholder="请选择">
                                                <el-option label="普通" :value="0"></el-option>
                                                <el-option label="神圣" :value="1"></el-option>
                                                <el-option label="火焰" :value="2"></el-option>
                                                <el-option label="自然" :value="3"></el-option>
                                                <el-option label="冰霜" :value="4"></el-option>
                                                <el-option label="暗影" :value="5"></el-option>
                                                <el-option label="奥术" :value="6"></el-option>
                                            </el-select>
                                        </el-form-item>
                                        <el-form-item label="最小伤害">
                                            <el-input type="number" size="mini" min="0" max="99999" v-model="item.dmg_min2"></el-input>
                                        </el-form-item>
                                        <el-form-item label="最大伤害">
                                            <el-input type="number" size="mini" min="0" max="99999" v-model="item.dmg_max2"></el-input>
                                        </el-form-item></el-tab-pane>
                                </el-tabs>



                            </el-form>
                        </el-tab-pane>
                        <el-tab-pane label="属性" >
                            <el-form ref="form" label-width="0px" size="mini">
                                <el-form-item v-show="item.StatsCount>=1">
                                    <component-item-stats-select :stat_tpye.sync="item.stat_type1" :stat_value.sync="item.stat_value1"></component-item-stats-select>
                                </el-form-item>
                                <el-form-item v-show="item.StatsCount>=2">
                                    <component-item-stats-select :stat_tpye.sync="item.stat_type2" :stat_value.sync="item.stat_value2"></component-item-stats-select>
                                </el-form-item>
                                <el-form-item v-show="item.StatsCount>=3">
                                    <component-item-stats-select :stat_tpye.sync="item.stat_type3" :stat_value.sync="item.stat_value3"></component-item-stats-select>
                                </el-form-item>
                                <el-form-item v-show="item.StatsCount>=4">
                                    <component-item-stats-select :stat_tpye.sync="item.stat_type4" :stat_value.sync="item.stat_value4"></component-item-stats-select>
                                </el-form-item>
                                <el-form-item v-show="item.StatsCount>=5">
                                    <component-item-stats-select :stat_tpye.sync="item.stat_type5" :stat_value.sync="item.stat_value5"></component-item-stats-select>
                                </el-form-item>
                                <el-form-item v-show="item.StatsCount>=6">
                                    <component-item-stats-select :stat_tpye.sync="item.stat_type6" :stat_value.sync="item.stat_value6"></component-item-stats-select>
                                </el-form-item>
                                <el-form-item v-show="item.StatsCount>=7">
                                    <component-item-stats-select :stat_tpye.sync="item.stat_type7" :stat_value.sync="item.stat_value7"></component-item-stats-select>
                                </el-form-item>
                                <el-form-item v-show="item.StatsCount>=8">
                                    <component-item-stats-select :stat_tpye.sync="item.stat_type8" :stat_value.sync="item.stat_value8"></component-item-stats-select>
                                </el-form-item>
                                <el-form-item v-show="item.StatsCount>=9">
                                    <component-item-stats-select :stat_tpye.sync="item.stat_type9" :stat_value.sync="item.stat_value9"></component-item-stats-select>
                                </el-form-item>
                                <el-form-item v-show="item.StatsCount>=10">
                                    <component-item-stats-select :stat_tpye.sync="item.stat_type10" :stat_value.sync="item.stat_value10"></component-item-stats-select>
                                </el-form-item>
                                <br>
                                <el-button-group>
                                    <el-button type="primary" size="mini" icon="el-icon-plus" @click="item.StatsCount++" :disabled="item.StatsCount===10"></el-button>
                                    <el-button type="primary" size="mini" icon="el-icon-minus" @click="item.StatsCount--" :disabled="item.StatsCount===0"></el-button>
                                </el-button-group>
                            </el-form>
                        </el-tab-pane>
                        <el-tab-pane label="抗性" >
                            <el-form ref="form" label-width="80px" size="mini">
{{--                                <el-form-item label="神圣">--}}
{{--                                    <el-input type="number" size="mini" min="0" max="99999" v-model="item.holy_res"></el-input>--}}
{{--                                </el-form-item>--}}
                                <el-form-item label="火焰">
                                    <el-input type="number" size="mini" min="0" max="99999" v-model="item.fire_res"></el-input>
                                </el-form-item>
                                <el-form-item label="自然">
                                    <el-input type="number" size="mini" min="0" max="99999" v-model="item.nature_res"></el-input>
                                </el-form-item>
                                <el-form-item label="冰霜">
                                    <el-input type="number" size="mini" min="0" max="99999" v-model="item.frost_res"></el-input>
                                </el-form-item>
                                <el-form-item label="暗影">
                                    <el-input type="number" size="mini" min="0" max="99999" v-model="item.shadow_res"></el-input>
                                </el-form-item>
                                <el-form-item label="奥术">
                                    <el-input type="number" size="mini" min="0" max="99999" v-model="item.arcane_res"></el-input>
                                </el-form-item>
                            </el-form>
                        </el-tab-pane>

                    </el-tabs>



                </el-col>
            </el-row>
        </div>
        <span slot="footer" class="dialog-footer">
            <el-button type="primary" @click="seve()">保存</el-button>
            <el-button @click="close()">关闭</el-button>
          </span>
    </el-dialog>
</template>
<script>
    Vue.component("component-item-edit", {
        props:["item","visible"],
        data() {
            return {
            };
        },
        template:"#tmp-item-edit",
        watch:{
        },
        methods:{
            close(){
                this.$emit('update:visible', false);
            },
            seve(){
                let classes=this.item.classes[1].split('_');
                this.item.class=parseInt(classes[0]);
                this.item.subclass=parseInt(classes[1]);
                post('itemSave', this.item,res=>{
                    if(res.err===0){
                        this.$message({
                            message: '保存成功，修改物品需要重启服务器',
                            type: 'success'
                        });
                        this.$emit('update:item', this.item);
                    }else{
                        this.$message.error('保存失败，请检查是否有空数据');
                    }
                },this)
            }
        }
    });
</script>
<style>
    .el-form-item--mini.el-form-item{
        margin-bottom: 0;
    }
</style>
